package com.example.springbootdemo.controller;


import com.example.springbootdemo.entity.StudentComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.PostConstruct;

@Controller
@ResponseBody
public class TestController {

    // 1. 得到日志对象
    private static final Logger log = LoggerFactory.getLogger(TestController.class);

    @Value("${school}") // 注意使用&{XXX}
    private String myConfig;

    @Autowired
    private StudentComponent student;

    @PostConstruct
    public void doPostConstruct(){
        System.out.println("====================");
        System.out.println(student);
        System.out.println("====================");
    }

    @RequestMapping("/hello")
    public String sayHello(){
        // 打印日志
        log.trace("i'm trace");
        log.debug("i'm debug");
        log.info("i'm info");
        log.warn("i'm warn");
        log.error("i'm error");
        return "Hello Springboot"+myConfig;
    }


}
